From 42c2037b14186a40e3eed6fee3c8a6ed7df0efc6 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Wed, 14 Oct 2009 21:51:36 +0000 Subject: [PATCH] * follow-up to r57728 switched to use global wfShellExec function --- includes/GlobalFunctions.php | 52 ---------------------------------- includes/upload/UploadBase.php | 6 +--- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f762ec02bc..c23a64c860 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3346,55 +3346,3 @@ function wfBCP47( $code ) { $langCode = implode ( '-' , $codeBCP ); return $langCode; } - -/* Fixes shell_exec problems on Windows - * From http://www.php.net/manual/de/function.shell-exec.php#52826 via bug 21140 - */ -function wfRunExternal($cmd,&$code) { - $descriptorspec = array( - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to - 2 => array("pipe", "w") // stderr is a file to write to - ); - - $pipes= array(); - $process = proc_open($cmd, $descriptorspec, $pipes); - - $output= ""; - - if (!is_resource($process)) return false; - - #close child's input imidiately - fclose($pipes[0]); - - stream_set_blocking($pipes[1],false); - stream_set_blocking($pipes[2],false); - - $todo= array($pipes[1],$pipes[2]); - - while( true ) { - $read= array(); - if( !feof($pipes[1]) ) $read[]= $pipes[1]; - if( !feof($pipes[2]) ) $read[]= $pipes[2]; - - if (!$read) break; - - $ready= stream_select($read, $write=NULL, $ex= NULL, 2); - - if ($ready === false) { - break; #should never happen - something died - } - - foreach ($read as $r) { - $s= fread($r,1024); - $output.= $s; - } - } - - fclose($pipes[1]); - fclose($pipes[2]); - - $code= proc_close($process); - - return $output; -} diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 7926861bd5..1e33e79300 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -813,11 +813,7 @@ abstract class UploadBase { # that does not seem to be worth the pain. # Ask me (Duesentrieb) about it if it's ever needed. $output = array(); - if ( wfIsWindows() ) { - $output = wfRunExternal($command, $exitCode); - } else { - exec( "$command 2>&1", $output, $exitCode ); - } + $output = wfShellExec($command, $exitCode); # map exit code to AV_xxx constants. -- 2.20.1